package com.han.shadow.customerapp.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.han.shadow.customerapp.R;
import com.han.shadow.customerapp.activity.GoodsActivity;
import com.han.shadow.customerapp.bean.Business;

import java.util.List;

/**
 * Created by ACE on 2016/4/20 0020.
 */
public class MyBusinessAdapter extends BaseAdapter {

    private List<Business> businesses;
    private LayoutInflater inflater;


    public MyBusinessAdapter(List<Business> businesses,LayoutInflater inflater){
        this.businesses = businesses;
        this.inflater = inflater;
    }

    @Override
    public int getCount() {
        return businesses.size();
    }

    @Override
    public Object getItem(int position) {
        return businesses.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
}

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        convertView = inflater.inflate(R.layout.activity_business_style,null);
        final Business bus = businesses.get(position);
        TextView busInfo = (TextView)convertView.findViewById(R.id.busInfo);
        busInfo.setText(bus.getInformation());
        TextView busName = (TextView)convertView.findViewById(R.id.busName);
        busName.setText(bus.getName());


//        busName.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(context, GoodsActivity.class);
//                intent.putExtra("busID",bus.getId());
//                context.startActivity(intent);
//            }
//        });

        return convertView;
    }
}
